/*
 * Copyright 2022-2023 the original author(https://github.com/wj596)
 * 
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */
package org.jsets.fastboot.flowable.service;

import java.io.InputStream;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jsets.fastboot.flowable.model.dto.FlowModelQuery;
import org.jsets.fastboot.flowable.model.dto.FlowModelSettingParam;
import org.jsets.fastboot.flowable.model.dto.ProcessNode;
import org.jsets.fastboot.flowable.model.entity.CompositeModel;
import java.util.Optional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * 聚合流程模型
 * @author wangjie (https://github.com/wj596)
 * @date 2021.06.25 11:23
 */
public interface ICompositeModelService extends IService<CompositeModel>{

	/**
	 * 导入Bpmn模型文件
	 * @param fileName 文件名称
	 * @param inputStream 文件流程
	 */
	void importBpmnModelFile(String fileName, InputStream inputStream);
	
	void settingModel(FlowModelSettingParam param);
	
	/**
	 * 保存钉钉模型
	 * @param FlowModel model
	 */
	void saveDingModel(CompositeModel model);
	
	/**
	 * 分页查询流程模型
	 * @param criteria 查询条件
	 * @return Page<Model>
	 */
	Page<CompositeModel> selectPage(FlowModelQuery criteria);

	/**
	 * 根据KEY查找模型
	 * @param key
	 * @return Optional<FlowModel>
	 */
	Optional<CompositeModel> findByKey(String key);
	
	/**
	 * 根据部署ID获取模型
	 * @param deploymentId 部署ID
	 * @return Optional<FlowModel>
	 */
	Optional<CompositeModel> findByDeploymentId(String deploymentId);
	
	/**
	 * 根据部署主键获取流程图输入流
	 * @param deploymentId 部署主键
	 * @return InputStream
	 */
	InputStream getImageByDeploymentId(String deploymentId);
	
	
	InputStream getHighlightImage(String processInstanceId);
	
	/**
	 * 删除流程模型.
	 *
	 * @param id 主键
	 */
	void deleteById(String id);

	/**
	 * 遍历节点
	 * @param modelId 模型主键
	 * @return List<FlowElement>
	 */
	List<ProcessNode> iterateFlowElements(String modelId);
}